home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / ZSI / generate / utility.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  6KB  |  160 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import re
  5. from ZSI import EvaluateException
  6. from ZSI.TCcompound import Struct
  7. from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError
  8. from ZSI.wstools.Utility import SplitQName
  9. from ZSI.wstools.Namespaces import SCHEMA
  10.  
  11. NCName_to_ModuleName = lambda name: re.sub('\\.', '_', TextProtect(name))
  12.  
  13. NCName_to_ClassName = lambda name: re.sub('\\.', '_', TextProtect(name))
  14.  
  15. TextProtect = lambda s: re.sub('[-./:# ]', '_', s)
  16.  
  17. TextProtectAttributeName = lambda name: TextProtect('_%s' % name)
  18.  
  19. Namespace2ModuleName = lambda ns: TextProtect(ns.lstrip('http://')).rstrip('_')
  20.  
  21. def GetModuleBaseNameFromWSDL(wsdl):
  22.     if not wsdl.name:
  23.         pass
  24.     base_name = wsdl.services[0].name
  25.     base_name = SplitQName(base_name)[1]
  26.     if base_name is None:
  27.         return None
  28.     
  29.     return NCName_to_ModuleName(base_name)
  30.  
  31.  
  32. namespace_name = lambda cls, ns: 'ns%s' % len(cls.alias_list)
  33.  
  34. class NamespaceAliasDict:
  35.     alias_dict = { }
  36.     alias_list = []
  37.     
  38.     def add(cls, ns):
  39.         if cls.alias_dict.has_key(ns):
  40.             return None
  41.         
  42.         cls.alias_dict[ns] = (Namespace2ModuleName(ns), '%s' % namespace_name(cls, ns))
  43.         cls.alias_list.append(ns)
  44.  
  45.     add = classmethod(add)
  46.     
  47.     def getModuleName(cls, ns):
  48.         if cls.alias_dict.has_key(ns):
  49.             return cls.alias_dict[ns][0]
  50.         
  51.         msg = 'failed to find import for schema "%s"' % ns + 'possibly missing @schemaLocation attribute.'
  52.         if ns in SCHEMA.XSD_LIST:
  53.             msg = 'missing built-in typecode for schema "%s"' % ns
  54.         
  55.         raise WsdlGeneratorError, msg
  56.  
  57.     getModuleName = classmethod(getModuleName)
  58.     
  59.     def getAlias(cls, ns):
  60.         if cls.alias_dict.has_key(ns):
  61.             return cls.alias_dict[ns][1]
  62.         
  63.         msg = 'failed to find import for schema "%s"' % ns + 'possibly missing @schemaLocation attribute.'
  64.         if ns in SCHEMA.XSD_LIST:
  65.             msg = 'missing built-in typecode for schema "%s"' % ns
  66.         
  67.         raise WsdlGeneratorError, msg
  68.  
  69.     getAlias = classmethod(getAlias)
  70.     
  71.     def getNSList(cls):
  72.         return tuple(cls.alias_list)
  73.  
  74.     getNSList = classmethod(getNSList)
  75.  
  76.  
  77. class StringWriter:
  78.     
  79.     def __init__(self, val = None):
  80.         self.data = []
  81.         if val:
  82.             self.data.append(val)
  83.         
  84.  
  85.     
  86.     def set(self, val):
  87.         if self.data:
  88.             self.data = None
  89.             self.data = []
  90.         
  91.         self.data.append(val)
  92.  
  93.     
  94.     def write(self, val):
  95.         self.data.append(val)
  96.  
  97.     
  98.     def getvalue(self):
  99.         if self.data:
  100.             return ''.join(self.data)
  101.         else:
  102.             return ''
  103.  
  104.     
  105.     def __iadd__(self, val):
  106.         self.data.append(val)
  107.         return self
  108.  
  109.     
  110.     def __str__(self):
  111.         return self.getvalue()
  112.  
  113.  
  114.  
  115. class MessageContainer:
  116.     pass
  117.  
  118.  
  119. def GetPartsSubNames(args, wsdl):
  120.     do_extended = True
  121.     WriteServiceModule = WriteServiceModule
  122.     SchemaDescription = SchemaDescription
  123.     import wsdl2python
  124.     wsm = WriteServiceModule(wsdl, do_extended = do_extended)
  125.     wsm.gatherNamespaces()
  126.     toReturn = []
  127.     for arg in args:
  128.         argSubnames = []
  129.         for l in wsm.usedNamespaces.values():
  130.             for schema in l:
  131.                 sd = SchemaDescription(do_extended = do_extended)
  132.                 sd.fromSchema(schema)
  133.                 argNamespace = arg.element[0]
  134.                 if sd.targetNamespace == argNamespace:
  135.                     for i in sd.items:
  136.                         argElementType = arg.element[1]
  137.                         if str(argElementType) == str(i.content.name):
  138.                             argSubnames = []
  139.                             if i.content.mgContent != None:
  140.                                 for c in i.content.mgContent:
  141.                                     nValue = 'None'
  142.                                     if c.isWildCard():
  143.                                         nValue = 'any'
  144.                                     elif c.attributes.has_key('name'):
  145.                                         nValue = c.attributes['name']
  146.                                     elif c.attributes.has_key('ref'):
  147.                                         nValue = c.attributes['ref'][1]
  148.                                     
  149.                                     argSubnames.append(nValue)
  150.                                 
  151.                             
  152.                         i.content.mgContent != None
  153.                     
  154.             
  155.         
  156.         toReturn.append(argSubnames)
  157.     
  158.     return toReturn
  159.  
  160.